package com.skd.ssh.service.base.impl;

import com.skd.ssh.dao.base.BaseDao;
import com.skd.ssh.service.base.BaseService;
import com.skd.ssh.web.query.BaseQuery;
import com.skd.ssh.web.query.PageResult;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

public abstract class BaseServiceImpl<T> implements BaseService<T> {

    public abstract BaseDao<T> getDao();
    public T getEntityById(Serializable id) {
        return this.getDao().get(id);
    }
    public Long getMaxId() {
        return this.getDao().getMaxId();
    }
    @Transactional(readOnly=false)
    public void saveEntry(T t) {
        this.getDao().save(t);
    }
    @Transactional(readOnly=false)
    public void updateEntry(T t) {
        this.getDao().update(t);
    }
    @Transactional(readOnly=false)
    public void deleteEntry(Serializable id) {
        this.getDao().delete(id);
    }
    public PageResult<T> getEntityPageResult(BaseQuery baseQuery){
        return this.getDao().findPageResult(baseQuery);
    }
}
